package com.tensquare.qa.config;

import com.tensquare.qa.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @description
 * @author: xu1
 **/
//mvc 额外的配置类都这样，继承 、实现个 配套的 类， ---配置注解
@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

//    WebMvcConfigurationSupport 进去这个 类，方法贼多，ctrl＋F12 找方法 -定位


    @Autowired
    private JwtInterceptor jwtInterceptor;
    //注册拦截器要声明拦截器对象和要拦截的对象
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
         .addPathPatterns("/**")//配置拦截的路径
         .excludePathPatterns("/**/login/**");//放行的路径
    }

}
